home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Include / TextPart.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  5.0 KB  |  168 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            TextPart.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef _TEXTPART_
  14. #define _TEXTPART_
  15.  
  16. #ifndef _TEXTDEF_
  17. #include "TextDef.h"
  18. #endif
  19.  
  20. // ----- Framework Includes -----
  21.  
  22. #ifndef FWPARTING_H
  23. #include "FWParting.h"
  24. #endif
  25.  
  26. // ----- OpenDoc Includes -----
  27.  
  28. #ifndef _STORAGEU_
  29. #include "StorageU.h"
  30. #endif
  31.  
  32. //========================================================================================
  33. // Forward class declarations
  34. //========================================================================================
  35.  
  36. class FW_CFrame;
  37. class XMPSemanticInterface;
  38. class __machdl COpenDocText;
  39. class CTextFrame;
  40. class CTextFacet;
  41. class FW_CSelection;
  42. class CTextSelection;
  43.  
  44.  
  45. //========================================================================================
  46. // CTextPart
  47. //========================================================================================
  48.  
  49. class CTextPart : public FW_CEmbeddingPart
  50. {
  51.     friend CTextSelection;
  52.     
  53. // ----- Types
  54. public:
  55.     typedef char Justification;
  56.     
  57. // ----- Constants
  58. public:
  59.     enum { kFontMenu = 5, kSizeMenu = 6, kEmbedMenu = 7 };
  60.     enum { kRootFrameId = 'root', kContentFrameId = 'cont', kRulerFrameId = 'rulr' };
  61.     enum { kNumberOfTools = 4 };
  62.     enum { kMarginPictHeight = 9, kMarginPictWidth = 5 };
  63.     enum { kToolHeights = 13, kToolWidths = 19 };
  64.     enum { kRulerHeight = 16, kRulerWidth = 614 };
  65.     enum { kRulerRulerHeight = 20, kRulerToolsHeight = kToolHeights + 9 }; 
  66.     
  67. private:
  68.     static const XMPPropertyName kTextPropertyName;
  69.     static const XMPValueType kTextensionTextType;
  70.     
  71. // ----- Initialization and termination
  72. public:        
  73.     CTextPart();
  74.     virtual ~ CDECL CTextPart();
  75.  
  76.     virtual void Initialize();
  77.  
  78. // ----- from FW_CEmbeddingPart
  79. public:
  80.     virtual void            Draw(XMPFacet* xmpFacet, XMPShape* invalidShape);
  81. //    virtual FW_CFrame*            NewScrollerFrameTree(XMPFrame* xmpFrame);
  82.     virtual FW_CFrame*         NewFrame(XMPFrame* xmpFrame, XMPTypeToken presentation);
  83.     virtual FW_CSelection*    NewSelection();
  84.     virtual void             InternalizeContent(XMPStorageUnit* storageUnit);
  85.     virtual void            ExternalizeContent(XMPStorageUnit* storageUnit);
  86.     virtual void            DoAdjustMenus(XMPMenuBar* menuBar);
  87.     virtual FW_Boolean        DoMenuEvent(XMPMenuBar *menuBar, XMPCommandID commandID);
  88.     virtual XMPValueType GetContentPropertyValueType() const;
  89.     virtual FW_CProxyRun*        NewProxyRun();
  90.     virtual XMPTypeToken    GetDefaultPresentation() const;
  91.  
  92.     
  93. // ----- New Methods
  94. public:
  95.     COpenDocText*                GetEditText()
  96.                                 { return fEditText; }
  97.     
  98.     // The following methods apply to the current selection.
  99.     virtual void            SetFontSize(short fontSize);
  100.     virtual Boolean            GetFontSize(short& fontSize) const;
  101.     virtual void            SetFont(const Str255 fontName);
  102.     virtual Boolean            GetFont(Str255 fontName) const;
  103.     virtual void            SetSelectionJustification(Justification justify) const;
  104.     virtual Justification    GetSelectionJustification() const;
  105.     CTextFacet*                GetAnyFacet(XMPTypeToken presentation = 0);
  106.     
  107.  
  108.     void                    HandleEmbedMenuEvent(short item);
  109.     void                    HandleEmbedPart(XMPPart* xmpPart, const FW_CRect& frameShape);
  110.     
  111.     XMPTypeToken            GetMainPresentation() const
  112.                                 { return fMainPresentation; }
  113.     XMPTypeToken            GetRulerPresentation() const
  114.                                 { return fRulerPresentation; }
  115.                                           
  116.     Boolean                    IsDrawing()
  117.                                 { return fIsDrawing; }
  118.     void                    SetEmbeddedRunFrame(CTextFrame *frame)
  119.                                 { fEmbeddedRunFrame = frame; }
  120.     CTextFrame*                GetEmbeddedRunFrame()
  121.                                 { return fEmbeddedRunFrame; }
  122.     void                    SetEmbeddedRunFacet(CTextFacet *facet)
  123.                                 { fEmbeddedRunFacet = facet; }
  124.     CTextFacet*                GetEmbeddedRunFacet()
  125.                                 { return fEmbeddedRunFacet; }
  126.     void                    SetEmbeddedRunEvent(XMPEventData event)
  127.                                 { fEvent = event; }
  128.     XMPEventData            GetEmbeddedRunEvent()
  129.                                 { return fEvent; }
  130.     static CTextPart*        GetCurrentPart()
  131.                                 { return gCurrentPart; }                
  132.     
  133. private:
  134.     static void            InitializeTextension();
  135.     
  136.     void                    CreateEditText();
  137.     void                    StuffInTheText(FW_PlatformHandle text, Size textSize);
  138.     void                    StuffInTheStyles(FW_PlatformHandle styles, Size stylesSize);
  139.             
  140. // ----- Data Members
  141. private:
  142.     MenuHandle                fFontMenu;
  143.     MenuHandle                fSizeMenu;
  144.     MenuHandle                fEmbedMenu;
  145.     
  146.     XMPTypeToken            fRulerPresentation;
  147.     XMPTypeToken            fMainPresentation;
  148.     XMPTypeToken            fScrollerPresentation;
  149.  
  150.     COpenDocText*            fEditText;
  151.     
  152.     // Hack. When my Textension run object's draw method is called by Textension I need to
  153.     // be able to pass it some parameters. I store those parameters here before calling methods
  154.     // on Textension.
  155.     
  156.     Boolean                    fIsDrawing;
  157.     CTextFrame                *fEmbeddedRunFrame;
  158.     CTextFacet                *fEmbeddedRunFacet;
  159.     XMPEventData            fEvent;
  160.     
  161.     // Global variable used to pass current part through to Textension during
  162.     // internalization and cloning.
  163.     
  164.     static CTextPart*        gCurrentPart;
  165. };
  166.  
  167. #endif
  168.